package ATM;

import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class ItemFrame extends JFrame {
    public ItemFrame(){
        this.setLayout(null);

        MyButton askButton = new MyButton("查询",100,50,this);
        MyButton pwdChangeButton = new MyButton("改密码",100,120,this);
        MyButton saveButton = new MyButton("存钱",300,40,this);
        MyButton getMoneyButton = new MyButton("取款",300,90,this);
        MyButton takeCardButton = new MyButton("取卡",300,140,this);

        this.setSize(500,300);
        this.setVisible(true);
        this.setDefaultCloseOperation(3);
        this.setLocationRelativeTo(null);
        this.setTitle("请选择操作项目");


        askButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                askMoney();
            }
        });

        saveButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                saveMoney();
            }
        });

        getMoneyButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                getMoney();
            }
        });

        pwdChangeButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                pwdChange();
            }
        });

        takeCardButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                exit();
            }
        });
    }

    private void askMoney(){
        this.dispose();
        new AskFrame();
    }

    private void saveMoney(){
        this.dispose();
        new SaveFrame();
    }

    private void getMoney(){
        this.dispose();
        new getMoneyFrame();
    }

    private void pwdChange(){
        this.dispose();
        new pwdChangeFrame();
    }

    private void exit(){
        this.dispose();
        new ExitFrame();
    }
}
